123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378 |
- <template>
- <!-- 页面头部 -->
- <HomePageHead></HomePageHead>
- <!-- 导航栏 -->
- <HomePageNavigation1></HomePageNavigation1>
- <!-- 列表页广告一 -->
- <HomeTopTen :imgurl="adList[0]" v-if="adList[0]"></HomeTopTen>
- <!-- 面包屑导航 -->
- <div class="breadcrumb">
- <div class="inner">
- <span class="location">当前位置:</span>
- <el-breadcrumb :separator-icon="ArrowRight">
- <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
- <el-breadcrumb-item :to="{ path: `/newsList/${routLevelId}` }">{{ routLevelTitle }}</el-breadcrumb-item>
- <!-- <el-breadcrumb-item>文章详情</el-breadcrumb-item> -->
- <el-breadcrumb-item>{{ routeNewsTtitle }}</el-breadcrumb-item>
- </el-breadcrumb>
- </div>
- </div>
- <!-- 资讯列表 -->
- <div class="newsDetail">
- <div class="inner">
- <div class="innerLeft">
- <div class="LeftTop">
- <h1>{{ newsDetail.title }}</h1>
- <p>
- 来源: <span>{{ newsDetail.copyfrom }}</span>
- 作者: <span>{{ newsDetail.author }}</span>
- 发布时间: <span>{{ time }}</span>
- <!-- 浏览量: <span>{{ newsDetail.hits }}</span> -->
- </p>
- <img :src="newsDetail.imgurl" alt="">
- </div>
- <div class="leftBottom" v-html="newsDetail.content"></div>
- <!-- 免责声明: -->
- <div class="disclaimer" v-if="newsDetail.fromurl">
- <p>原文链接:{{ newsDetail.fromurl }}</p>
- <p>[免责声明]本文来源于网络转载,仅供学习交流使用,不构成商业目的。 版权归原作者所有,如涉及作品内容,版权和其他问题,请在30日与本网联系,我们将第一时间处理。</p>
- </div>
- </div>
- <div class="innerRight">
- <!-- 热点资讯1 -->
- <div class="hotList1">
- <DetailHotNews></DetailHotNews>
- </div>
- <!-- 热点资讯2 -->
- <div class="hotList2">
- <DetailHotNews2></DetailHotNews2>
- </div>
- </div>
- </div>
- </div>
- <!-- 页面底部 -->
- <HomeFoot1></HomeFoot1>
- </template>
- <script setup>
- import { onMounted } from 'vue'
- import { ElBreadcrumb, ElBreadcrumbItem } from 'element-plus'
- import { ArrowRight } from '@element-plus/icons-vue'
- const nuxtApp = useNuxtApp();
- const axios = nuxtApp.$axios;
- //获得跳转过来的id
- const route = useRoute();
- const articleId = route.params.id; //获得该页面的id
- const listid = route.query.listId; //获得该页面的id
- const name = route.query.listName; //获得该页面的id
- // 定义响应式数据
- const seoData = ref({
- title: '三农资讯网',
- description: '默认描述',
- keywords: '默认关键词',
- image: 'https://example.com/default-image.jpg'
- });
- // 在 onMounted 钩子中获取数据
- onMounted(async () => {
- try {
- const response = await axios.get(`/web/selectWebsiteArticleInfo?articleid=${articleId}`);
- const data = response.data; // 假设接口返回的数据在 data 字段中
- // 更新 seoData
- seoData.value = {
- title: data.title,
- description: data.seo_description,
- keywords: data.keyword,
- image: data.introduce
- };
- } catch (error) {
- console.error('获取 SEO 数据失败:', error);
- // 设置默认值
- seoData.value = {
- title: '三农资讯网',
- description: '默认描述',
- keywords: '默认关键词',
- image: 'https://example.com/default-image.jpg'
- };
- }
- });
- // 监听 seoData 的变化,动态设置 SEO 字段
- watch(seoData, (newVal) => {
- if (newVal.title) { // 确保 title 有值
- useSeoMeta({
- title: newVal.title, // 使用动态值
- description: newVal.description,
- ogTitle: newVal.title,
- ogDescription: newVal.description,
- ogImage: newVal.image,
- twitterTitle: newVal.title,
- twitterDescription: newVal.description,
- twitterImage: newVal.image,
- keywords: newVal.keywords
- });
- }
- }, { immediate: true });
- const newsDetail = ref({})
- const routeNewsTtitle = ref("");
- //发布日期
- const time = ref("");
- //路径
- const routLevelTitle = ref("");
- const routLevelId = ref("");
- //获取详情
- const getNewsInfo = async () => {
- const response = await axios.get(`/web/selectWebsiteArticleInfo?articleid=${articleId}`);
- newsDetail.value = response.data;
- routLevelTitle.value = newsDetail.value.cat_name
- console.log(123145)
- routLevelId.value = newsDetail.value.category_id
- time.value = newsDetail.value.updated_at.split(' ')[0]
- if (newsDetail.value.title.length >= 30) {
- routeNewsTtitle.value = newsDetail.value.title.substr(0, 30) + "...";
- } else {
- routeNewsTtitle.value = newsDetail.value.title
- }
- }
- function getDays(time) {
- const date = new Date(time);
- const year = date.getFullYear();
- const month = date.getMonth() + 1;
- const day = date.getDate();
- return `${month}-${day}`;
- }
- //获得广告
- const adList = ref("");
- const aa='DETAIL'
- const getadList = async () => {
- try {
- const response = await axios.get(`/web/getWebsiteAdvertisement?ad_tag=${aa}`);
- adList.value = response.data;
- } catch (error) {
- console.error(error);
- }
- }
- onMounted(() => {
- getNewsInfo()
- getadList()
- })
- </script>
- <style lang="less" scoped>
- //导航条
- .breadcrumb {
- width: 100%;
- height: 22px;
- margin-bottom: 30px;
- font-family: Microsoft YaHei, Microsoft YaHei;
- font-weight: 400;
- font-size: 20px;
- color: #666666;
- line-height: 23px;
- text-align: left;
- font-style: normal;
- text-transform: none;
- .el-breadcrumb::v-deep {
- display: inline-block;
- vertical-align: -4px;
- }
- /deep/.el-breadcrumb__inner a,
- /deep/.el-breadcrumb__inner.is-link {
- color: #666666;
- font-weight: 400;
- text-decoration: none;
- transition: var(--el-transition-color);
- }
- span {
- font-family: Microsoft YaHei, Microsoft YaHei;
- font-weight: 400;
- font-size: 20px;
- color: #666666;
- line-height: 23px;
- text-align: left;
- font-style: normal;
- text-transform: none;
- }
- span:hover {
- color: #666666;
- }
- .location {
- margin-right: 20px;
- width: 100px;
- height: 22px;
- font-family: Microsoft YaHei, Microsoft YaHei;
- font-weight: 400;
- font-size: 20px;
- color: #666666;
- line-height: 23px;
- text-align: left;
- font-style: normal;
- text-transform: none;
- }
- }
- // 资讯列表
- .newsDetail {
- width: 100%;
- //height: 1400px;
- margin-bottom: 70px;
- .inner {
- width: 1200px;
- //height: 1400px;
- overflow: hidden;
- font-size: 16px;
- .innerLeft {
- // height: 1400px;
- border-top: 1px solid #139602;
- .LeftTop {
- height: 522px;
- margin-top: 50px;
- >h1 {
- line-height: 40px;
- margin-bottom: 30px;
- font-family: Microsoft YaHei, Microsoft YaHei;
- font-weight: bold;
- font-size: 30px;
- color: #333333;
- }
- >p {
- height: 18px;
- line-height: 18px;
- font-family: Microsoft YaHei, Microsoft YaHei;
- font-weight: 400;
- font-size: 14px;
- color: #999999;
- span {
- margin-right: 40px;
- }
- }
- >img {
- width: 680px;
- height: 382px;
- padding: 50px 0px 60px 55px;
- }
- }
- .leftBottom {
- width: 790px;
- // height: 754px;
- margin-top: 76px;
- font-size: 20px;
- line-height: 38px;
- margin-bottom: 30px;
- ul>li img{
- width: 790px;
- height: 382px;
- }
- img{
- width: 790px;
- height: 382px;
- }
-
- p.tinymce-material {
- img {
- width: 790px;
- }
- }
- >h3,
- >p {
- text-indent: 2em;
- width: 790px;
- font-family: Microsoft YaHei, Microsoft YaHei;
- font-size: 20px;
- color: #333333;
- line-height: 38px;
- padding-bottom: 30px;
- img {
- width: 790px;
- }
- }
- >h3 {
- font-weight: 600px;
- }
- >p {
- font-weight: 400;
- }
- }
- .disclaimer {
- width: 790px;
- overflow: hidden;
- border-top: 1px solid #e6e6e6;
- padding: 30px 0px;
- color: #999999;
- font-size: 17px;
- p {
- width: 790px;
- line-height: 30px;
- }
- }
- }
- .innerRight {
- width: 381px;
- // height: 605px;
- overflow: hidden;
- border-top: 1px solid #139602;
- .hotList1 {
- margin-bottom: 50px;
- }
- }
- }
- }
- .leftBottom::v-deep p img,
- .leftBottom::v-deep img,
- .leftBottom::v-deep video {
- max-width: 700px;
- }
- .leftBottom::v-deep h1,
- .leftBottom::v-deep h2,
- .leftBottom::v-deep h3,
- .leftBottom::v-deep h4,
- .leftBottom::v-deep h5,
- .leftBottom::v-deep h6 {
- font-size: 20px;
- font-weight: 500;
- }
- </style>
|